var vm = new Vue({
  el : '#app',
  extends: CommonTools,
  
  data : function(){
    return {
      conditions: {
        time: '',
      },
      pageData: {
        page: 1,
        rows: 10,
        total: 0,
        results: []
      },
      currentRow: null,
      
    }
  },
  
  filters: {

    /**
     * 状态名称
     */
    stateName(state) {
     if(state=="unsubmit"){
    	 return '未提交'
     }else if(state=="submit"){
    	 return "已提交"
     }else if(state=="unpass"){
     	return "未通过"
     }else{
    	 return "已通过"
     }
    },
    
  },
   computed: {
  readonly: function(){
      return this.leave && (this.leave == 'unpass');
    },
    
    
  },

  methods: {  
    
    //新增
    onCreate() {
      window.location.href = "../../gLeaveController.do?goEdit";
    },
    
    onEdit(id) {
      window.location.href = "../../gLeaveController.do?goEdit2&id="+id;
    },
    
    
    onQuery() {
      this.reloadActivity(1, 10);
    },
    
    /**
     * 重新加载
     */
    reload(){
      this.reloadActivity();
    },
    

    /**
     * 加载
     */
    reloadActivity(page, pageSize) {
      var self = this
      page = page? page: this.pageData.page;
      pageSize = pageSize? pageSize: this.pageData.rows;
      var code = JSON.parse(sessionStorage.user).teaNum;
      
      var url = "../../gLeaveController.do?datagrid2&page=" 
        + page + "&rows=" + pageSize + "&state=submit"+"&code=" + code;
      this.get(url).then(data => { 
        data.results.map(function (item){
        	item.leStart = item.leStart.split("T")[0];
        	item.leEnd = item.leEnd.split("T")[0];
        })      
        self.pageData = data; 
      }).catch(err => {
        self.showError(err);
      });
    },
  },
  
  created() {
    this.reload();
  },
  
});